package cn.rengy.web.framework.wxmp.subscribemsg;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
/**
 * 
 * @author rengy
 *
 */
@Controller
@RequestMapping(value = "/wx/subscribemsg")
public class SubscribeMsgController {
	private static Logger logger = LoggerFactory.getLogger(SubscribeMsgController.class);
	@Autowired
	private SubscribeMsgService subscribeMsgService;
	/**
	 * @param openid
	 * @param template_id
	 * @param action 用户点击动作，”confirm”代表用户确认授权，”cancel”代表用户取消授权
	 * @param scene 订阅场景值
	 * @param reserved 请求带入原样返回
	 * @throws Exception
	 */
	@RequestMapping()
	public ModelAndView subscribemsg(@RequestParam(value = "openid", required = false) String openid,
			@RequestParam("template_id") String template_id,@RequestParam("reserved") String reserved,
			@RequestParam("action") String action,@RequestParam("scene") int scene) throws Exception{
		if(logger.isDebugEnabled()){
			logger.debug("action:{},scene:{},openid:{},template_id:{},reserved:{}",action,scene,openid,template_id,reserved);
		}
		return subscribeMsgService.subscribemsg(openid, template_id, reserved, action, scene);
    }
	
	@RequestMapping("/index")
	public ModelAndView index() throws Exception{
		return subscribeMsgService.index();
    }
}
